package com.smz.controller;

import com.smz.entity.UserRole;
import com.smz.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserRoleController {


    @Autowired
    private UserRoleService userRoleService;

    @PostMapping("addUserRole")
    public ResponseEntity<String > addUserRole(@RequestBody UserRole userRole){
        String s = userRoleService.addUserRole(userRole);
        return ResponseEntity.ok(s);
    }

    @DeleteMapping("deleteUserRole/{roleId}/{userId}")
    public ResponseEntity<String> deleteUserRole(@PathVariable("roleId")String roleId,
                                                 @PathVariable("userId")String userId){
        String s = userRoleService.deleteUserRole(new UserRole(0, roleId, userId));

        return ResponseEntity.ok(s);
    }


}
